<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }

        .father{
            display: flex;
            flex-direction: column;
            position: relative;
            width: 500px;
            height: 500px;
            border: 5px;
        }

        .child{
            
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);
            background-color: aqua;
        }
    </style>
</head>
<body>
    <div class="father" >
        <div class="child">
                元素的大小不确定也能进行精准的居中布局
        </div>
    </div>
</body>
</html>